<template>
  <view class="box">
    <view class="tou top" :style="'padding-top:' + statusBarHeight1 + 'px'">
      <image
        @click="fanhui"
        class="image1"
        src="https://pic.bangbangtongcheng.com/static/fanhui_bai.png"
      />
      公司认证
    </view>
    <scroll-view scroll-y class="scroll-view">
      <form>
        <view class="cu-form-group">
          <view class="title"> <span style="color: red">*</span>企业全称 </view>
          <input type="text" v-model="dprzData.enterpriseFullName" placeholder="请填写企业全称" />
        </view>
        <view class="cu-form-group">
          <view class="title"> <span style="color: red">*</span>统一社会信用代码 </view>
          <input
            type="text"
            v-if="!cxbj_jy"
            @input="fpNumInput"
            v-model="dprzData.unifiedSocialCreditCode"
            maxlength="18"
            placeholder="请填写统一社会信用代码"
          />
          <input
            type="text"
            @click="tishi"
            v-else
            @input="fpNumInput"
            disabled
            v-model="dprzData.unifiedSocialCreditCode"
            maxlength="18"
            placeholder="请填写统一社会信用代码"
          />
        </view>
        <view class="cu-form-group">
          <view class="title"> <span style="color: red">*</span>办公区域 </view>
          <picker
            @change="dictionariesChange"
            :data-index="index"
            range-key="valueName"
            :range="dictionaries"
          >
            <view class="picker">{{ index > -1 ? dictionaries[index].valueName : '请选择' }}</view>
          </picker>
        </view>
        <view class="cu-form-group">
          <view class="title"> <span style="color: red">*</span>企业地址 </view>
          <template v-if="dprzData.officeAddress">
            <input v-model="dprzData.officeAddress" />
          </template>
          <template v-else>
            <input
              v-model="dprzData.officeAddress"
              @click=""
              disabled="true"
              placeholder="请选择定位获取地址"
            />
          </template>
          <text
            class="cuIcon-locationfill text-orange"
            @click="openMap"
            style="color: #64b6a8"
          ></text>
        </view>
        <view class="cu-form-group">
          <view class="title"> 公司规模 </view>
          <picker
            @change="typeIndex8Chage"
            :data-index="index"
            range-key="valueName"
            :range="type8"
          >
            <view class="picker">{{
              typeIndex8 > -1 ? type8[typeIndex8].valueName : '请选择'
            }}</view>
          </picker>
        </view>
        <view class="cu-form-group">
          <view class="title"> <span style="color: red">*</span>法人姓名 </view>
          <input
            type="text"
            v-if="!cxbj_jy"
            v-model="dprzData.legalPersonName"
            placeholder="请填写法人姓名"
          />
          <input
            type="text"
            @click="tishi"
            v-else
            v-model="dprzData.legalPersonName"
            disabled
            placeholder="请填写法人姓名"
          />
        </view>
        <view class="cu-form-group">
          <view class="title"> <span style="color: red">*</span>经办人姓名 </view>
          <input type="text" v-model="dprzData.attentionLine" placeholder="请填写经办人姓名" />
        </view>
        <view class="cu-form-group">
          <view class="title"> <span style="color: red">*</span>经办人手机号 </view>
          <input
            type="text"
            @click="tishi"
            v-model="dprzData.operatorsTelephone"
            placeholder="请填写联系方式"
            disabled
          />
        </view>
        <view class="cu-form-group">
          <view class="title"> <span style="color: red">*</span>所属行业 </view>
          <picker
            @change="typeIndex9Chage"
            :data-index="index"
            range-key="valueName"
            :range="type9"
          >
            <view class="picker">{{
              typeIndex9 > -1 ? type9[typeIndex9].valueName : '请选择'
            }}</view>
          </picker>
        </view>
        <view class="cu-form-group">
          <view class="title"> <span style="color: red">*</span>营业执照 </view>
        </view>
        <view class="shangchuan">
          <view class="cu-form-group">
            <view class="grid col-4 grid-square flex-sub">
              <view
                class="bg-img"
                v-for="(item, index) in imgList1"
                :key="index"
                @tap="ViewImage1"
                :data-url="imgList1[index]"
              >
                <image :src="imgUrl + imgList1[index]" mode="aspectFit" />
                <view
                  class="cu-tag bg-red"
                  @tap.stop="DelImg1"
                  :data-index="index"
                  v-if="status != 0"
                >
                  <text class="cuIcon-close"></text>
                </view>
              </view>
              <view class="solids" @tap="ChooseImages(1)" v-if="imgList1.length < 1">
                <text class="cuIcon-cameraadd"></text>
              </view>
            </view>
          </view>
          <view
            style="font-size: 24rpx; color: #999999; background-color: #fff; padding-left: 40rpx"
          >
            上传要求信息清晰、最大2mb</view
          >
        </view>
        <view class="cu-form-group">
          <view class="title"> 法人身份证（人像面） </view>
        </view>
        <view class="sfz">
          <view class="cu-form-group">
            <view class="grid col-4 grid-square flex-sub">
              <view
                class="bg-img id_card"
                v-for="(item, index) in imgList2"
                :key="index"
                @tap="ViewImage2"
                :data-url="imgList2[index]"
              >
                <image :src="imgUrl + imgList2[index]" mode="aspectFit" />
                <view
                  class="cu-tag bg-red"
                  @tap.stop="DelImg2"
                  :data-index="index"
                  v-if="status != 0"
                >
                  <text class="cuIcon-close"></text>
                </view>
              </view>
              <view class="solids id_card" @tap="ChooseImages(2)" v-if="imgList2.length < 1">
                <view
                  style="
                    z-index: 1;
                    position: absolute;
                    width: 380rpx;
                    left: 50%;
                    top: 50%;
                    transform: translate(-50%, -50%);
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                  "
                >
                  <img
                    style="width: 60rpx; height: 60rpx"
                    src="https://pic.bangbangtongcheng.com/6579f8a312604aee9defb7d8837c1b0b"
                    alt=""
                  />
                  <view class="" style="margin-top: 11rpx; color: #64b6a8; font-size: 28rpx">
                    上传法人身份证（人像面）
                  </view>
                </view>
                <img
                  style="width: 100%; height: 100%"
                  src="https://pic.bangbangtongcheng.com/da4ad84ad67a4d9c901d8aeacaeef72f"
                  alt
                />
              </view>
            </view>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title"> 法人身份证（国徽面） </view>
        </view>
        <view class="sfz">
          <view class="cu-form-group">
            <view class="grid col-4 grid-square flex-sub">
              <view
                class="bg-img id_card"
                v-for="(item, index) in imgList3"
                :key="index"
                @tap="ViewImage3"
                :data-url="imgList3[index]"
              >
                <image :src="imgUrl + imgList3[index]" mode="aspectFit" />
                <view
                  class="cu-tag bg-red"
                  @tap.stop="DelImg3"
                  :data-index="index"
                  v-if="status != 0"
                >
                  <text class="cuIcon-close"></text>
                </view>
              </view>
              <view class="solids id_card" @tap="ChooseImages(3)" v-if="imgList3.length < 1">
                <view
                  style="
                    z-index: 1;
                    position: absolute;
                    width: 380rpx;
                    left: 50%;
                    top: 50%;
                    transform: translate(-50%, -50%);
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                  "
                >
                  <img
                    style="width: 60rpx; height: 60rpx"
                    src="https://pic.bangbangtongcheng.com/6579f8a312604aee9defb7d8837c1b0b"
                    alt=""
                  />
                  <view class="" style="margin-top: 11rpx; color: #64b6a8; font-size: 28rpx">
                    上传法人身份证（国徽面）
                  </view>
                </view>
                <img
                  style="width: 100%; height: 100%"
                  src="https://pic.bangbangtongcheng.com/6f240bc939fa48579c99ce4287752da0"
                  alt
                />
              </view>
            </view>
          </view>
        </view>
        <!-- 身份证 -->
        <view class="cu-form-group">
          <view class="title"> <span style="color: red">*</span>经办人身份证（人像面） </view>
        </view>
        <view class="sfz">
          <view class="cu-form-group">
            <view class="grid col-4 grid-square flex-sub">
              <view
                class="bg-img id_card"
                v-for="(item, index) in imgList9"
                :key="index"
                @tap="ViewImage9"
                :data-url="imgList9[index]"
              >
                <image :src="imgUrl + imgList9[index]" mode="aspectFit" />
                <view
                  class="cu-tag bg-red"
                  @tap.stop="DelImg9"
                  :data-index="index"
                  v-if="status != 0"
                >
                  <text class="cuIcon-close"></text>
                </view>
              </view>
              <view class="solids id_card" @tap="ChooseImages(9)" v-if="imgList9.length < 1">
                <view
                  style="
                    z-index: 1;
                    position: absolute;
                    width: 380rpx;
                    left: 50%;
                    top: 50%;
                    transform: translate(-50%, -50%);
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                  "
                >
                  <img
                    style="width: 60rpx; height: 60rpx"
                    src="https://pic.bangbangtongcheng.com/6579f8a312604aee9defb7d8837c1b0b"
                    alt=""
                  />
                  <view class="" style="margin-top: 11rpx; color: #64b6a8; font-size: 28rpx">
                    上传经办人身份证（人像面）
                  </view>
                </view>
                <img
                  style="width: 100%; height: 100%"
                  src="https://pic.bangbangtongcheng.com/da4ad84ad67a4d9c901d8aeacaeef72f"
                  alt
                />
              </view>
            </view>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title"> <span style="color: red">*</span>经办人身份证（国徽面） </view>
        </view>
        <view class="sfz">
          <view class="cu-form-group">
            <view class="grid col-4 grid-square flex-sub">
              <view
                class="bg-img id_card"
                v-for="(item, index) in imgList10"
                :key="index"
                @tap="ViewImage10"
                :data-url="imgList10[index]"
              >
                <image :src="imgUrl + imgList10[index]" mode="aspectFit" />
                <view
                  class="cu-tag bg-red"
                  @tap.stop="DelImg10"
                  :data-index="index"
                  v-if="status != 0"
                >
                  <text class="cuIcon-close"></text>
                </view>
              </view>
              <view class="solids id_card" @tap="ChooseImages(10)" v-if="imgList10.length < 1">
                <view
                  style="
                    z-index: 1;
                    position: absolute;
                    width: 380rpx;
                    left: 50%;
                    top: 50%;
                    transform: translate(-50%, -50%);
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                  "
                >
                  <img
                    style="width: 60rpx; height: 60rpx"
                    src="https://pic.bangbangtongcheng.com/6579f8a312604aee9defb7d8837c1b0b"
                    alt=""
                  />
                  <view class="" style="margin-top: 11rpx; color: #64b6a8; font-size: 28rpx">
                    上传经办人身份证（国徽面）
                  </view>
                </view>
                <img
                  style="width: 100%; height: 100%"
                  src="https://pic.bangbangtongcheng.com/6f240bc939fa48579c99ce4287752da0"
                  alt
                />
              </view>
            </view>
          </view>
        </view>
      </form>
      <!-- #ifdef MP-WEIXIN -->
      <!-- 该组件有调整，暂时用不上 -->
      <cropper v-if="false" ref="croop" :quality="1" resize: false :canScale="true"
      selWidth="624rpx" selHeight="416rpx" style='z-index:1000' @upload="myUpload"
      class="userHeader" />
      <!-- #endif -->
    </scroll-view>
    <!-- #ifndef MP-WEIXIN-->
    <gmy-img-cropper
      ref="gmyImgCropper"
      quality="1"
      cropperType="ratio"
      :ratio="1.5"
      fileType="png"
      imgSrc=""
      style="z-index: 1000"
      @getImg="myUpload"
    >
    </gmy-img-cropper>
    <!-- #endif -->
    <view class="tijiao">
      <view class="but" v-if="status == 0">审核中，请耐心等待</view>
      <view class="but" v-if="status != 0" @click="submit">提交</view>
    </view>
    <uniBall></uniBall>
  </view>
</template>
<script>
  import permision from '@/js_sdk/wa-permission/permission.js'
  //#ifdef H5
  import wxshare from '../../utils/index.js'
  //#endif
  //#ifdef MP-WEIXIN
  import cropper from '../../components/lxiaoxiao-cropper/lxiaoxiao-cropper.vue'
  //#endif

  // #ifndef MP-WEIXIN
  import gmyImgCropper from '../../components/gmy-img-cropper/gmy-img-cropper.vue'
  //#endif
  import { mapGetters } from 'vuex'
  export default {
    components: {
      // #ifndef MP-WEIXIN
      gmyImgCropper,
      //#endif
      //#ifdef MP-WEIXIN
      cropper,
      //#endif
    },
    data() {
      return {
        dprzData: {
          id: '',
          userId: '', //用户ID
          enterpriseFullName: '', //企业全称
          unifiedSocialCreditCode: '', //统一社会信用代码
          officeArea: '', //办公区域
          officeAddress: '', //办公地址
          longitude: '', //经度
          latitude: '', //纬度
          companySize: '', //公司规模
          legalPersonName: '', //法人姓名
          attentionLine: '', //经办人姓名
          operatorsTelephone: '', //经办人电话
          affiliationIndustry: '', //所属行业
          businessLicense: '', //营业执照
          legalPersonIdCardPortrait: '', //法人身份证（人像面）
          legalPersonIdCardNationalEmblemFace: '', //法人身份证（国徽面）
          handledByIdCardPortrait: '', //经办人身份证（人像面）
          handledByIdCardNationalEmblemFace: '', //经办人身份证（国徽面）
        },
        image: '',
        status: '2',
        imgList1: [],
        imgList2: [],
        imgList3: [],
        imgList9: [],
        imgList10: [],
        userInfo: uni.getStorageSync('Pduser'),
        index: -1,
        dictionaries: [],
        type8: [],
        typeIndex8: -1,
        type9: [],
        typeIndex9: -1,
        foutnum: 0,
        imgUrl: this.$imgSrc,
        amend: '',
        type: '',
        // 防抖
        anti_shake: false,
        // 是否重新编辑禁用
        cxbj_jy: false,
      }
    },
    computed: {
      ...mapGetters(['statusBarHeight1', 'userinfo']),
    },
    onLoad(e) {
      this.dprzData.operatorsTelephone = this.userInfo.phone
      if (uni.getStorageSync('locationState') == 1) {
        this.getLocation()
      }
      this.getDictionaries()
      this.getType()
      this.init()
      /* #ifdef H5 */
      this.jinzhi()
      /* #endif */
      this.amend = e.amend
      this.type = e.type
    },
    methods: {
      fpNumInput(e) {
        const o = e.target
        const inputRule = /[\W]/g
        this.$nextTick(function () {
          this.dprzData.unifiedSocialCreditCode = o.value.replace(inputRule, '')
        })
      },
      init() {
        let that = this
        that.imgList1 = []
        that.imgList2 = []
        that.imgList3 = []
        that.imgList9 = []
        that.imgList10 = []
        this.$myRequest
          .get('/api/mobile/personnelOwner/getEnterpriseCertificationById', {
            userId: that.userInfo.id,
          })
          .then((res) => {
            if (res.enterpriseCertification) {
              let obj = res.enterpriseCertification
              this.dprzData.userId = obj.userId
              if (obj.auditStatus == 1) {
                this.cxbj_jy = true
              }
              this.dprzData.id = obj.originalId || obj.id
              this.dprzData.enterpriseFullName = obj.enterpriseFullName
              this.dprzData.unifiedSocialCreditCode = obj.unifiedSocialCreditCode
              this.dprzData.officeArea = obj.officeArea
              this.type8.forEach((i, j) => {
                if (i.valueName == obj.companySize) {
                  this.typeIndex8 = j
                }
              })
              this.type9.forEach((i, j) => {
                if (i.valueName == obj.affiliationIndustry) {
                  this.typeIndex9 = j
                }
              })
              for (var i = 0; i < that.dictionaries.length; i++) {
                if (that.dictionaries[i].valueName == obj.officeArea) {
                  that.index = i
                }
              }
              this.dprzData.officeAddress = obj.officeAddress
              this.dprzData.longitude = obj.longitude
              this.dprzData.latitude = obj.latitude
              this.dprzData.companySize = obj.companySize
              this.dprzData.legalPersonName = obj.legalPersonName
              this.dprzData.attentionLine = obj.attentionLine
              this.dprzData.operatorsTelephone = obj.operatorsTelephone
              this.dprzData.affiliationIndustry = obj.affiliationIndustry

              obj.businessLicense && that.imgList1.push(obj.businessLicense)
              obj.legalPersonIdCardPortrait && that.imgList2.push(obj.legalPersonIdCardPortrait)
              obj.legalPersonIdCardNationalEmblemFace &&
                that.imgList3.push(obj.legalPersonIdCardNationalEmblemFace)
              obj.handledByIdCardPortrait && that.imgList9.push(obj.handledByIdCardPortrait)
              obj.handledByIdCardNationalEmblemFace &&
                that.imgList10.push(obj.handledByIdCardNationalEmblemFace)
              this.status = obj.auditStatus
            }
          })
      },
      tishi() {
        uni.showToast({
          title: '当前选择无法更改！',
          duration: 2000,
          icon: 'none',
        })
      },
      sumfountnum(e) {
        this.foutnum = e.detail.value.length
      },
      getDictionaries() {
        this.$myRequest
          .get('/mob/home/getDictionaries', {
            type: '7',
          })
          .then((res) => {
            this.dictionaries = res.list
          })
      },
      getType() {
        this.$myRequest
          .get('/api/mobile/personnelOwner/queryDataDictionaryList', {
            type: '8,9',
          })
          .then((res) => {
            res.dataDictionaryList.forEach((el) => {
              if (el.type == 8) {
                this.type8.push(el)
              } else if (el.type == 9) {
                this.type9.push(el)
              }
            })
          })
      },
      dictionariesChange(e) {
        this.index = e.detail.value
        this.dprzData.officeArea = this.dictionaries[this.index].valueName
      },
      typeIndex8Chage(e) {
        this.typeIndex8 = e.detail.value
        this.dprzData.companySize = this.type8[this.typeIndex8].valueName
      },
      typeIndex9Chage(e) {
        this.typeIndex9 = e.detail.value
        this.dprzData.affiliationIndustry = this.type9[this.typeIndex9].valueName
      },
      ViewImage1(e) {
        uni.previewImage({
          urls: this.imgList1,
          current: e.currentTarget.dataset.url,
        })
      },
      ViewImage2(e) {
        uni.previewImage({
          urls: this.imgList2,
          current: e.currentTarget.dataset.url,
        })
      },
      ViewImage3(e) {
        uni.previewImage({
          urls: this.imgList3,
          current: e.currentTarget.dataset.url,
        })
      },
      ViewImage9(e) {
        uni.previewImage({
          urls: this.imgList9,
          current: e.currentTarget.dataset.url,
        })
      },
      ViewImage10(e) {
        uni.previewImage({
          urls: this.imgList10,
          current: e.currentTarget.dataset.url,
        })
      },
      DelImg1(e) {
        uni.showModal({
          title: '',
          content: '确定要删除营业执照？',
          cancelText: '取消',
          confirmText: '确定',
          success: (res) => {
            if (res.confirm) {
              this.imgList1.splice(e.currentTarget.dataset.index, 1)
            }
          },
        })
      },
      DelImg2(e) {
        uni.showModal({
          title: '',
          content: '确定要删除法人身份证人像面？',
          cancelText: '取消',
          confirmText: '确定',
          success: (res) => {
            if (res.confirm) {
              this.imgList2.splice(e.currentTarget.dataset.index, 1)
            }
          },
        })
      },
      DelImg3(e) {
        uni.showModal({
          title: '',
          content: '确定要删除法人身份证国徽面？',
          cancelText: '取消',
          confirmText: '确定',
          success: (res) => {
            if (res.confirm) {
              this.imgList3.splice(e.currentTarget.dataset.index, 1)
            }
          },
        })
      },
      DelImg9(e) {
        uni.showModal({
          title: '',
          content: '确定要删除经办人身份证人像面？',
          cancelText: '取消',
          confirmText: '确定',
          success: (res) => {
            if (res.confirm) {
              this.imgList9.splice(e.currentTarget.dataset.index, 1)
            }
          },
        })
      },
      DelImg10(e) {
        uni.showModal({
          title: '',
          content: '确定要删除经办人身份证国徽面？',
          cancelText: '取消',
          confirmText: '确定',
          success: (res) => {
            if (res.confirm) {
              this.imgList10.splice(e.currentTarget.dataset.index, 1)
            }
          },
        })
      },
      jinzhi() {
        let _this = this
        let param = window.location.href.split('#')[0]
        uni.request({
          method: 'post',
          data: {
            url: param,
          },
          header: {
            'content-type': 'application/x-www-form-urlencoded',
          },
          url: 'https://www.bangbangtongcheng.com/conven//mob/login/getJsTicket.do',
          success(re) {
            _this.jinzhifx(re.data)
          },
        })
      },
      jinzhifx(data) {
        wxshare.config({
          debug: false, //是否打开调试
          appId: data.appId, // 公众号的唯一标识
          timestamp: data.timestamp, // 生成签名的时间戳
          nonceStr: data.nonce, // ，生成签名的随机串
          signature: data.signature, // 签名
          jsApiList: ['hideMenuItems'],
        })
        // 禁止分享
        wxshare.hideMenuItems({
          // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
          menuList: [
            'menuItem:share:appMessage',
            'menuItem:share:timeline',
            'menuItem:share:timeline',
            'menuItem:share:qq',
            'menuItem:favorite',
            'menuItem:share:QZone',
            'menuItem:openWithSafari',
          ],
        })
      },
      async ChooseImages(type) {
        if (type == 1) {
          this.ChooseImage1()
        }
        if (type == 2) {
          this.ChooseImage2()
        }
        if (type == 3) {
          this.ChooseImage3()
        }
        if (type == 9) {
          this.ChooseImage9()
        }
        if (type == 10) {
          this.ChooseImage10()
        }
      },
      ChooseImage1() {
        let _this = this
        _this.imgList1 = []
        uni.chooseImage({
          count: 1, //默认1
          sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
          // sourceType: ["album"], //从相册选择
          sourceType: ['camera', 'album'],
          success: (res) => {
            var imgFiles = res.tempFilePaths
            const tempFiles = res.tempFiles
            let length = ''
            // #ifdef H5
            length = tempFiles[0].name.length
            let resType = tempFiles[0].name.substring(length - 1, length)
            // #endif
            // #ifndef H5
            length = tempFiles[0].path.length
            let resType = tempFiles[0].path.substring(length - 1, length)
            // #endif
            if (resType != 'g' && resType != 'G') {
              uni.showToast({
                title: '不支持当前文件格式',
                icon: 'none',
              })
              return
            }
            if (imgFiles.length > 1) {
              uni.showToast({
                title: '图片最多不能超过1张',
                duration: 2000,
                icon: 'none',
              })
              return
            }
            var uper
            imgFiles.forEach((el) => {
              uni.showToast({
                title: '正在上传请稍后',
                icon: 'none',
                duration: 2000,
              })
              uper = uni.uploadFile({
                // 需要上传的地址
                url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
                // filePath 需要上传的文件
                filePath: el,
                name: 'file',
                success(res1) {
                  _this.imgList1.push(JSON.parse(res1.data).data[0].url)
                },
              })
            })
            // onProgressUpdate 上传对象更新的方法
            uper.onProgressUpdate(function (res) {})
          },
          fail: (fail) => {
            uni.showModal({
              title: '提示',
              content: '操作权限已被拒绝，请手动前往设置',
              confirmText: '立即设置',
              success: (res) => {
                if (res.confirm) {
                  if (plus.os.name === 'iOS') {
                    plus.runtime.openURL('app-settings://')
                  } else {
                    var Intent = plus.android.importClass('android.content.Intent')
                    var Settings = plus.android.importClass('android.provider.Settings')
                    var Uri = plus.android.importClass('android.net.Uri')
                    var mainActivity = plus.android.runtimeMainActivity()
                    var intent = new Intent()
                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
                    var uri = Uri.fromParts('package', mainActivity.getPackageName(), null)
                    intent.setData(uri)
                    mainActivity.startActivity(intent)
                  }
                }
              },
            })
          },
        })
      },
      ChooseImage2() {
        let _this = this
        _this.imgList2 = []
        uni.chooseImage({
          count: 1, //默认1
          sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
          // sourceType: ["album"], //从相册选择
          sourceType: ['camera', 'album'],
          success: (res) => {
            var imgFiles = res.tempFilePaths
            const tempFiles = res.tempFiles
            let length = ''
            // #ifdef H5
            length = tempFiles[0].name.length
            let resType = tempFiles[0].name.substring(length - 1, length)
            // #endif
            // #ifndef H5
            length = tempFiles[0].path.length
            let resType = tempFiles[0].path.substring(length - 1, length)
            // #endif
            if (resType != 'g' && resType != 'G') {
              uni.showToast({
                title: '不支持当前文件格式',
                icon: 'none',
              })
              return
            }
            if (imgFiles.length > 1) {
              uni.showToast({
                title: '图片最多不能超过1张',
                duration: 2000,
                icon: 'none',
              })
              return
            }
            var uper
            imgFiles.forEach((el) => {
              uni.showToast({
                title: '正在上传请稍后',
                icon: 'none',
                duration: 2000,
              })
              uper = uni.uploadFile({
                // 需要上传的地址
                url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
                // filePath 需要上传的文件
                filePath: el,
                name: 'file',
                success(res1) {
                  _this.imgList2.push(JSON.parse(res1.data).data[0].url)
                },
              })
            })
            // onProgressUpdate 上传对象更新的方法
            uper.onProgressUpdate(function (res) {})
          },
          fail: (fail) => {
            uni.showModal({
              title: '提示',
              content: '操作权限已被拒绝，请手动前往设置',
              confirmText: '立即设置',
              success: (res) => {
                if (res.confirm) {
                  if (plus.os.name === 'iOS') {
                    plus.runtime.openURL('app-settings://')
                  } else {
                    var Intent = plus.android.importClass('android.content.Intent')
                    var Settings = plus.android.importClass('android.provider.Settings')
                    var Uri = plus.android.importClass('android.net.Uri')
                    var mainActivity = plus.android.runtimeMainActivity()
                    var intent = new Intent()
                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
                    var uri = Uri.fromParts('package', mainActivity.getPackageName(), null)
                    intent.setData(uri)
                    mainActivity.startActivity(intent)
                  }
                }
              },
            })
          },
        })
      },
      ChooseImage3() {
        let _this = this
        _this.imgList3 = []
        uni.chooseImage({
          count: 1, //默认1
          sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
          // sourceType: ["album"], //从相册选择
          sourceType: ['camera', 'album'],
          success: (res) => {
            var imgFiles = res.tempFilePaths
            const tempFiles = res.tempFiles
            let length = ''
            // #ifdef H5
            length = tempFiles[0].name.length
            let resType = tempFiles[0].name.substring(length - 1, length)
            // #endif
            // #ifndef H5
            length = tempFiles[0].path.length
            let resType = tempFiles[0].path.substring(length - 1, length)
            // #endif
            if (resType != 'g' && resType != 'G') {
              uni.showToast({
                title: '不支持当前文件格式',
                icon: 'none',
              })
              return
            }
            if (imgFiles.length > 1) {
              uni.showToast({
                title: '图片最多不能超过1张',
                duration: 2000,
                icon: 'none',
              })
              return
            }
            var uper
            imgFiles.forEach((el) => {
              uni.showToast({
                title: '正在上传请稍后',
                icon: 'none',
                duration: 2000,
              })
              uper = uni.uploadFile({
                // 需要上传的地址
                url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
                // filePath 需要上传的文件
                filePath: el,
                name: 'file',
                success(res1) {
                  _this.imgList3.push(JSON.parse(res1.data).data[0].url)
                },
              })
            })
            // onProgressUpdate 上传对象更新的方法
            uper.onProgressUpdate(function (res) {})
          },
          fail: (fail) => {
            uni.showModal({
              title: '提示',
              content: '操作权限已被拒绝，请手动前往设置',
              confirmText: '立即设置',
              success: (res) => {
                if (res.confirm) {
                  if (plus.os.name === 'iOS') {
                    plus.runtime.openURL('app-settings://')
                  } else {
                    var Intent = plus.android.importClass('android.content.Intent')
                    var Settings = plus.android.importClass('android.provider.Settings')
                    var Uri = plus.android.importClass('android.net.Uri')
                    var mainActivity = plus.android.runtimeMainActivity()
                    var intent = new Intent()
                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
                    var uri = Uri.fromParts('package', mainActivity.getPackageName(), null)
                    intent.setData(uri)
                    mainActivity.startActivity(intent)
                  }
                }
              },
            })
          },
        })
      },
      ChooseImage9() {
        let _this = this
        _this.imgList9 = []
        uni.chooseImage({
          count: 1, //默认1
          sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
          // sourceType: ["album"], //从相册选择
          sourceType: ['camera', 'album'],
          success: (res) => {
            var imgFiles = res.tempFilePaths
            const tempFiles = res.tempFiles
            let length = ''
            // #ifdef H5
            length = tempFiles[0].name.length
            let resType = tempFiles[0].name.substring(length - 1, length)
            // #endif
            // #ifndef H5
            length = tempFiles[0].path.length
            let resType = tempFiles[0].path.substring(length - 1, length)
            // #endif
            if (resType != 'g' && resType != 'G') {
              uni.showToast({
                title: '不支持当前文件格式',
                icon: 'none',
              })
              return
            }
            if (imgFiles.length > 1) {
              uni.showToast({
                title: '图片最多不能超过1张',
                duration: 2000,
                icon: 'none',
              })
              return
            }
            var uper
            imgFiles.forEach((el) => {
              uni.showToast({
                title: '正在上传请稍后',
                icon: 'none',
                duration: 2000,
              })
              uper = uni.uploadFile({
                // 需要上传的地址
                url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
                // filePath 需要上传的文件
                filePath: el,
                name: 'file',
                success(res1) {
                  _this.imgList9.push(JSON.parse(res1.data).data[0].url)
                },
              })
            })
            // onProgressUpdate 上传对象更新的方法
            uper.onProgressUpdate(function (res) {})
          },
          fail: (fail) => {
            uni.showModal({
              title: '提示',
              content: '操作权限已被拒绝，请手动前往设置',
              confirmText: '立即设置',
              success: (res) => {
                if (res.confirm) {
                  if (plus.os.name === 'iOS') {
                    plus.runtime.openURL('app-settings://')
                  } else {
                    var Intent = plus.android.importClass('android.content.Intent')
                    var Settings = plus.android.importClass('android.provider.Settings')
                    var Uri = plus.android.importClass('android.net.Uri')
                    var mainActivity = plus.android.runtimeMainActivity()
                    var intent = new Intent()
                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
                    var uri = Uri.fromParts('package', mainActivity.getPackageName(), null)
                    intent.setData(uri)
                    mainActivity.startActivity(intent)
                  }
                }
              },
            })
          },
        })
      },
      ChooseImage10() {
        let _this = this
        _this.imgList10 = []
        uni.chooseImage({
          count: 1, //默认1
          sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
          // sourceType: ["album"], //从相册选择
          sourceType: ['camera', 'album'],
          success: (res) => {
            var imgFiles = res.tempFilePaths
            const tempFiles = res.tempFiles
            let length = ''
            // #ifdef H5
            length = tempFiles[0].name.length
            let resType = tempFiles[0].name.substring(length - 1, length)
            // #endif
            // #ifndef H5
            length = tempFiles[0].path.length
            let resType = tempFiles[0].path.substring(length - 1, length)
            // #endif
            if (resType != 'g' && resType != 'G') {
              uni.showToast({
                title: '不支持当前文件格式',
                icon: 'none',
              })
              return
            }
            if (imgFiles.length > 1) {
              uni.showToast({
                title: '图片最多不能超过1张',
                duration: 2000,
                icon: 'none',
              })
              return
            }
            var uper
            imgFiles.forEach((el) => {
              uni.showToast({
                title: '正在上传请稍后',
                icon: 'none',
                duration: 2000,
              })
              uper = uni.uploadFile({
                // 需要上传的地址
                url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
                // filePath 需要上传的文件
                filePath: el,
                name: 'file',
                success(res1) {
                  _this.imgList10.push(JSON.parse(res1.data).data[0].url)
                },
              })
            })
            // onProgressUpdate 上传对象更新的方法
            uper.onProgressUpdate(function (res) {})
          },
          fail: (fail) => {
            uni.showModal({
              title: '提示',
              content: '操作权限已被拒绝，请手动前往设置',
              confirmText: '立即设置',
              success: (res) => {
                if (res.confirm) {
                  if (plus.os.name === 'iOS') {
                    plus.runtime.openURL('app-settings://')
                  } else {
                    var Intent = plus.android.importClass('android.content.Intent')
                    var Settings = plus.android.importClass('android.provider.Settings')
                    var Uri = plus.android.importClass('android.net.Uri')
                    var mainActivity = plus.android.runtimeMainActivity()
                    var intent = new Intent()
                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
                    var uri = Uri.fromParts('package', mainActivity.getPackageName(), null)
                    intent.setData(uri)
                    mainActivity.startActivity(intent)
                  }
                }
              },
            })
          },
        })
      },
      fanhui() {
        uni.navigateBack({
          delta: 1,
        })
      },
      async getLocation() {
        this.getLocation1()
      },
      getLocation1() {
        let _this = this
        uni.getLocation({
          type: 'gcj02',
          highAccuracyExpireTime: '3000',
          success(res) {
            console.log(res)
            _this.latitude = res.latitude
            _this.longitude = res.longitude
            // _this.openMap();
          },
          fail(res) {
            console.log(res, '经纬度没有授权')
            uni.setStorageSync('locationState', 0)
            if (uni.getStorageSync('locationState') == 0) {
              uni.showModal({
                title: '提示',
                content: '您已关闭位置权限或获取位置信息失败',
                success: function (res) {
                  if (res.confirm) {
                    // plus.runtime.openURL("app-settings:");
                    if (plus.os.name === 'iOS') {
                      plus.runtime.openURL('app-settings://')
                    } else {
                      var Intent = plus.android.importClass('android.content.Intent')
                      var Settings = plus.android.importClass('android.provider.Settings')
                      var Uri = plus.android.importClass('android.net.Uri')
                      var mainActivity = plus.android.runtimeMainActivity()
                      var intent = new Intent()
                      intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
                      var uri = Uri.fromParts('package', mainActivity.getPackageName(), null)
                      intent.setData(uri)
                      mainActivity.startActivity(intent)
                    }
                  } else if (res.cancel) {
                    console.log('用户点击取消')
                  }
                },
              })
              return false
            }
          },
        })
      },
      openMap() {
        let that = this
        if (that.latitude == '' || that.longitude == undefined) {
          this.getLocation()
          return
        } else {
          uni.chooseLocation({
            latitude: that.latitude,
            longitude: that.longitude,
            success: function (res) {
              that.dprzData.officeAddress = res.address
              that.dprzData.latitude = res.latitude
              that.dprzData.longitude = res.longitude
            },
          })
        }
      },
      // 提交
      submit() {
        let that = this
        if (this.anti_shake) {
          return false
        }
        let data = {}
        var status = true
        if (!that.userInfo.id) {
          uni.showToast({
            title: '请先登录',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.dprzData.enterpriseFullName) {
          uni.showToast({
            title: '请填写企业全称',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (that.dprzData.enterpriseFullName.length > 30) {
          uni.showToast({
            title: '企业名称上限为30个字符',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.dprzData.unifiedSocialCreditCode) {
          uni.showToast({
            title: '请填写统一社会信用代码',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.dprzData.officeArea) {
          uni.showToast({
            title: '请选择办公区域',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.dprzData.officeAddress) {
          uni.showToast({
            title: '请选择办公地址',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.dprzData.longitude) {
          uni.showToast({
            title: '请选择办公地址',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.dprzData.legalPersonName) {
          uni.showToast({
            title: '请填写法人姓名',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.dprzData.attentionLine) {
          uni.showToast({
            title: '请填写经办人姓名',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.dprzData.operatorsTelephone) {
          uni.showToast({
            title: '请填写经办人手机号',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (!that.dprzData.affiliationIndustry) {
          uni.showToast({
            title: '请选择所属行业',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (that.imgList1.length <= 0) {
          uni.showToast({
            title: '请上传营业执照',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        // if (that.imgList2.length <= 0) {
        // 	uni.showToast({
        // 		title: "请上传法人身份证人像面",
        // 		icon: "none",
        // 		mask: true,
        // 	});
        // 	status = false;
        // 	return false;
        // }
        // if (that.imgList3.length <= 0) {
        // 	uni.showToast({
        // 		title: "请上传法人身份证国徽面",
        // 		icon: "none",
        // 		mask: true,
        // 	});
        // 	status = false;
        // 	return false;
        // }
        if (that.imgList9.length <= 0) {
          uni.showToast({
            title: '请上传经办人身份证人像面',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        if (that.imgList10.length <= 0) {
          uni.showToast({
            title: '请上传经办人身份证国徽面',
            icon: 'none',
            mask: true,
          })
          status = false
          return false
        }
        this.dprzData.userId = that.userInfo.id
        this.dprzData.businessLicense = that.imgList1[0]
        if (that.imgList2.length) {
          this.dprzData.legalPersonIdCardPortrait = that.imgList2[0]
        }
        if (that.imgList3.length) {
          this.dprzData.legalPersonIdCardNationalEmblemFace = that.imgList3[0]
        }
        this.dprzData.handledByIdCardPortrait = that.imgList9[0]
        this.dprzData.handledByIdCardNationalEmblemFace = that.imgList10[0]
        if (status) {
          this.anti_shake = true
          this.$myRequest
            .post('/api/mobile/personnelOwner/enterpriseCertificationOrEdit', this.dprzData)
            .then((res) => {
              if (res.success && res.code == 200) {
                uni.showToast({
                  title: res.msg,
                  icon: 'none',
                  mask: true,
                })
                setTimeout(() => {
                  this.anti_shake = false
                }, 500)
                if (res.msg == '当前企业已存在无法认证，请更换！') {
                  return
                }
                if (that.type) {
                  setTimeout(() => {
                    uni.switchTab({
                      url: '/pages/index/index',
                    })
                  }, 500)
                  return
                }
                that.init()
              } else {
                uni.showToast({
                  title: res.msg,
                  icon: 'none',
                  mask: true,
                })
                that.init()
              }
            })
        }
      },
    },
  }
</script>
<style lang="less" scoped>
  .tou {
    position: relative;
    width: 100%;
    text-align: center;
    line-height: 88rpx;
    font-size: 36rpx;
    color: #fff;
    background-color: #64b6a8;

    .image1 {
      position: absolute;
      width: 32rpx;
      height: 32rpx;
      // top: 116rpx;
      left: 30rpx;
    }
  }
</style>
<style lang="less" scoped>
  .box {
    padding-bottom: 140rpx;
  }

  .scroll-view {
    /* #ifdef MP  */
    height: calc(100vh - var(--status-bar-height) - 88rpx - 5px - 22px - 144rpx);
    /* #endif */
    /* #ifdef H5 || APP-PULS */
    height: calc(100vh - var(--status-bar-height) - 88rpx - 5px - 144rpx);
    /* #endif */
    /* #ifdef APP */
    height: calc(100vh - var(--status-bar-height) - 88rpx - 5px - 144rpx);
    /* #endif */
  }

  .tijiao {
    position: fixed;
    width: 100%;
    bottom: 0rpx;
    padding-bottom: 40rpx;
    background-color: #fff;
    z-index: 99;

    checkbox {
      vertical-align: top;
      margin-right: 6rpx;
      margin-left: 40rpx;
    }

    span {
      font-size: 26rpx;
    }

    .but {
      width: 670rpx;
      height: 80rpx;
      background: #64b6a8;
      border-radius: 50rpx;
      font-size: 34rpx;
      text-align: center;
      line-height: 80rpx;
      color: #fff;
      margin-top: 24rpx;
      margin-left: 40rpx;
    }
  }

  .jieshao {
    background-color: #fff;

    .kuang {
      position: relative;
      width: 670rpx;
      min-height: 80rpx;
      margin-left: 40rpx;
      // padding-bottom: 40rpx;
      background-color: #fff;
      border: 1px solid #c9c9c9;

      .biaoqian {
        height: 40rpx;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        margin-right: 10rpx;
        color: #64b6a8;
      }

      textarea {
        width: 620rpx;
        margin-left: 24rpx;
        margin-top: 14rpx;
        line-height: 50rpx;
        letter-spacing: 2rpx;
      }

      p {
        position: absolute;
        bottom: 20rpx;
        right: 20rpx;
        color: #999999;
      }
    }
  }

  .cu-form-group uni-picker .picker {
    text-align: left;
  }

  .cu-form-group .title {
    font-weight: 600;
    font-size: 34rpx;
  }

  .grid.col-4.grid-square > uni-view {
    width: 212rpx;
    height: 212rpx;
  }

  /* .sfz {
  .grid.col-4.grid-square > uni-view {
    width: 670rpx;
    height: 360rpx;
    border-radius: 10rpx;
  }
} */
  .sfz .id_card {
    width: 670rpx !important;
    height: 360rpx !important;
    border-radius: 10rpx !important;
    padding-bottom: 0px !important;
  }

  .grid.col-4.grid-square > uni-view:nth-child(3n) {
    margin-right: 0;
  }
</style>
